﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DA
{
    public class NhatKyPhong_DA
    {
        QLKhachSanDataContext ql ;
        public List<NhatKyPhong> LayDSNhatKyPhong()
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.NhatKyPhongs.ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public DateTime LaySoNgayDenTheoMa(int ma)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.NhatKyPhongs.Where(p => p.MaNhatKy == ma).Select(p =>p.NgayDen.Value).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public DateTime LaySoNgayDiTheoMa(int ma)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.NhatKyPhongs.Where(p => p.MaNhatKy == ma).Select(p => p.NgayDi.Value).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
        public int LaySoLuongKhachTheoMaNK(int ma)
        {
            try
            {
                ql = new QLKhachSanDataContext();
                return ql.NhatKyPhongs.Where(p => p.MaNhatKy == ma).Select(p => p.SoLuong.Value).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ql.Dispose();
            }
        }
       
    }
}
